#include <algorithm>
#include <cstdio>

const int N = 500005, mod = 1e9 + 7;
int n, tot = 1;
long long m;
int a[N], tr[N << 1][2], l[N << 1], r[N << 1], siz[N << 1], sum[2][N][32], ptr[N];

inline long long qpow(long long base, long long exp) {
  long long res = 1;
  while (exp) {
    if (exp & 1) {
      (res *= base) %= mod;
    }
    exp >>= 1;
    (base *= base) %= mod;
  }
  return res;
}

inline void insert(int x, int id) {
  int cur = 1;
  for (int i = 30; ~i; --i) {
    bool ch = (x >> i) & 1;
    if (tr[cur][ch] == 0) {
      tr[cur][ch] = ++tot;
      l[tot] = id;
    }
    cur = tr[cur][ch];
    r[cur] = id;
    ++siz[cur];
  }
}

inline long long query() {
  long long res = 0;
  for (int i = 1; i <= n; ++i) ptr[i] = 1;
  for (int i = 30; ~i; --i) {
    long long cnt = 0;
    bool nxt = 0;
    for (int j = 1; j <= n; ++j) {
      cnt += 0ll + siz[tr[ptr[j]][!((a[j] >> i) & 1)]];
    }
    if (cnt >= m) {
      res |= 1ll << i;
      nxt = 1;
    } else {
      nxt = 0, m -= cnt;
    }
    for (int j = 1; j <= n; ++j) {
      ptr[j] = tr[ptr[j]][((a[j] >> i) & 1) ^ nxt];
    }
  }
  return res;
}

inline long long qsum(int x, int L, int R) {
  if (L == 0 || R == 0) return 0;
  long long res = 0;
  for (int i = 0; i < 31; ++i) {
    (res += (sum[!((x >> i) & 1)][R][i] - sum[!((x >> i) & 1)][L - 1][i]) % mod *
            ((1ll << i) % mod) % mod) %= mod;
  }
  return res;
}

inline long long getsum(long long k) {
  long long res = k * m % mod;
  for (int i = 1; i <= n; ++i) {
    ptr[i] = 1;
  }
  for (int i = 30; ~i; --i) {
    bool ch = (k >> i) & 1;
    if (ch == 0) {
      for (int j = 1; j <= n; ++j) {
        (res +=
         qsum(a[j], l[tr[ptr[j]][(a[j] >> i & 1) ^ 1]], r[tr[ptr[j]][(a[j] >> i & 1) ^ 1]])) %= mod;
      }
    }
    for (int j = 1; j <= n; ++j) ptr[j] = tr[ptr[j]][(a[j] >> i & 1) ^ ch];
  }
  return res;
}

signed main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("CF241B.in", "r", stdin);
  freopen("CF241B.out", "w", stdout);
#endif
#endif

  scanf("%d%lld", &n, &m);
  m <<= 1;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  std::sort(a + 1, a + n + 1);
  l[1] = 1, r[1] = n, siz[1] = n;
  for (int i = 1; i <= n; ++i) {
    insert(a[i], i);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 31; ++j) {
      sum[0][i][j] = sum[0][i - 1][j];
      sum[1][i][j] = sum[1][i - 1][j];
      ++sum[(a[i] >> j) & 1][i][j];
    }
  }
  long long k = query(), ans = getsum(k);
  (ans *= qpow(2, mod - 2)) %= mod;
  printf("%lld", ans);
  return 0;
}